<template>
  <div class="wxWelcomLink">
    <el-form :rules="rules" :model="link" label-width="120px" style="margin-top: 10px">
      <el-form-item label="图文标题" prop="title">
        <el-input class="al-width-300" v-model="link.title" placeholder="请输入图文标题" maxlength="15"
                  show-word-limit/>
      </el-form-item>
      <el-form-item label="图文地址" prop="link">
        <el-input class="al-width-300"
                  v-model="link.url"
                  placeholder="请输入图文地址"/>
      </el-form-item>
      <el-form-item label="图文描述" prop="note">
        <el-input class="al-width-300" :rows="4"
                  resize="none"
                  type="textarea" v-model="link.desc" placeholder="请输入图文描述"/>
      </el-form-item>
      <el-form-item label="图文封面">
        <wx-file-upload
          :list="link.picurl"
          tips="支持jpg/jpeg/png格式，建议200*200" fileTypes="png,jpg,jpeg"
          :limit="1" @success="linkCover"/>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import WxFileUpload from "@/components/wxqy/wxFileUpload/wxFileUpload.vue";
import {formValite} from "@/utils/validate";

export default {
  name: "wxWelcomLink",
  components: {WxFileUpload},
  props: ['model'],
  data() {
    return {
      link: this.model || {},
      rules: {
        title: [{required: true, message: '请输入图文标题', trigger: 'blur'}],
        url: [{required: true, message: '请输入图文地址', trigger: 'blur'}],
      }
    }
  },
  methods: {
    linkCover(file) {
      this.link.picurl = file.url
    },
    findData() {
      let flag = formValite(this.link, this.rules, this)
      return {success: flag, data: this.link}
    }
  }
}
</script>

<style scoped lang="scss">
.wxWelcomLink {
  ::v-deep.el-form-item {
    margin-bottom: 22px;
  }
}
</style>
